home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / comm / misc / DragonDaemon.lha / DragonDaemon-Install / Entwickler / ARexx-Demos / CheckDDaemon.rexx next >
OS/2 REXX Batch file  |  1999-05-08  |  3KB  |  124 lines

  1. /* CheckDDaemon V1.0 
  2. Loggt die Zählerzustände beim Aufruf mit, und vergleicht sie mit den letzten Werten. Unterschiede werden
  3. mittels Requester angezeigt. 
  4. */
  5.  
  6. p0  ="[Anlage]"
  7. p1  ="[Katja ]"
  8. p2  ="[Chef  ]"
  9. p3  ="[Axel  ]"
  10. p4  ="[ISDN  ]"
  11. Waehrung="DM"
  12. Log     ="ram:DD_Counterliste.txt"
  13. FONT    = XEN
  14. SIZE    = 11
  15.  
  16.  
  17.  
  18.  
  19. DM      =" "waehrung
  20. titel ="CheckDDaemon V1.0"
  21. nl      ="0a"x
  22. parse arg port
  23. port=strip(port)
  24.   if port="?" then call SYNT
  25.   if port="" then port="X"
  26.   if port<0 then port="X"
  27.   if port>4 then port="X"
  28. abfrageport=port
  29.   IF ~EXISTS("libs:rexxreqtools.library") THEN DO
  30.   SAY "Brauche RexxReqTools.library"
  31.   EXIT
  32.   END
  33.   IF ~SHOW('libraries','rexxreqtools.library') THEN DO
  34.   CALL ADDLIB("rexxreqtools.library",0,-30)
  35.   END
  36.  
  37. options results
  38.   if exists(Log) then call Checklog 
  39.   call makelog
  40.   exit
  41.  
  42. SCHREIBELOG:
  43.   call open(out,log,"A")
  44.   call writeln(out,"DDlog: "Auslese)
  45.   call close(out)
  46.   return
  47.  
  48. AUSLESEN:
  49.   Address "DragonDaemon"
  50.   DD_GETCOUNTER QUIET
  51.   if rc=1 then do
  52.           say "Es ist ein Fehler beim Counter auslesen aufgetreten..."
  53.           exit
  54.         end
  55.   Auslese=RESULT
  56.   return
  57.  
  58. MAKELOG:
  59.   call open(out,log,"W")
  60.   call writeln(out,"Dragon Daemon - Telefon Log Datei"nl)
  61.   call AUSLESEN
  62.   outgoing="DDlog: "auslese
  63.   call writeln(out,outgoing)
  64.   call close(out)
  65.   return
  66.  
  67. CHECKLOG:
  68.   call open(in,log,"R")
  69.   laenge=seek(in,0,e);position=laenge
  70.   if laenge>100 then position=laenge-100
  71.   call seek(in,position,b)
  72.   buf=readch(in,100)
  73.   pos=index(buf,"DDlog: ")
  74.   if pos~=0 then do
  75.     buf=substr(buf,pos)
  76.     end
  77.   pos=length(buf); oldbuf=substr(buf,1,pos-1) 
  78.   call close(in)
  79.   call AUSLESEN
  80.   
  81.   do i=0 to 4 ;dif.i=0; end 
  82.  
  83.   if word(newbuf,4)>=word(oldbuf,4) then dif.0=word(newbuf,4)-word(oldbuf,4)
  84.   if word(newbuf,5)>=word(oldbuf,5) then dif.1=word(newbuf,5)-word(oldbuf,5)
  85.   if word(newbuf,6)>=word(oldbuf,6) then dif.2=word(newbuf,6)-word(oldbuf,6)  
  86.   if word(newbuf,7)>=word(oldbuf,7) then dif.3=word(newbuf,7)-word(oldbuf,7)
  87.   if word(newbuf,8)>=word(oldbuf,8) then dif.4=word(newbuf,8)-word(oldbuf,8)
  88.   
  89.  
  90.   if abfrageport="0" then xxx=p0
  91.   if abfrageport="1" then xxx=p1
  92.   if abfrageport="2" then xxx=p2
  93.   if abfrageport="3" then xxx=p3
  94.   if abfrageport="4" then xxx=p4
  95.  
  96.   do i=0 to 4 
  97.     if dif.i=0 then dif.i=0.00
  98.     dif.i=trunc(dif.i,2)
  99.     end
  100.   call schreibelog
  101.  
  102.   if abfrageport="X"then do
  103.     call ausgabe2
  104.     end
  105.   if abfrageport~="X" then do
  106.     call ausgabe1
  107.     end
  108.   exit
  109.  
  110. AUSGABE1:
  111.   Address "DragonDaemon"
  112.   text="Angefallende Kosten seit dem "word(oldbuf,2)" "word(oldbuf,3)||nl||nl"Port"abfrageport" "xxx":"dif.abfrageport||dm
  113.   CALL rtezrequest(text,'_Ende',Titel,'rtez_flags = ezreqf_centertext' 'rt_font = '||FONT||'.font/'||SIZE 'rtez_defaultresponse = 0')
  114.   return
  115. AUSGABE2:
  116.   Address "DragonDaemon"
  117.   text="Angefallende Kosten seit dem "word(oldbuf,2)" "word(oldbuf,3)||nl||nl"Anlage "p0":"dif.0||dm||nl"Port1  "p1":"dif.1||dm||nl"Port2  "p2":"dif.2||dm||nl"Port3  "p3":"dif.3||dm||nl"Port4  "p4":"dif.4||dm
  118.   CALL rtezrequest(text,'_Ende',Titel,'rtez_flags = ezreqf_centertext' 'rt_font = '||FONT||'.font/'||SIZE 'rtez_defaultresponse = 0')
  119.   return
  120.  
  121. SYNT:
  122.   say "Syntax:"nl"CheckDDaemon <port>"nl||nl"<Port> (0-4) bestimmt den Port (0=Anlagen Zähler)"nl"        X managed alle Ports (Default)"
  123.   exit
  124.